<? 
	$mess = "";
	if(isset($_POST['submit'])){
		$tnr_nguoinhan = addslashes($_POST['tnr_nguoinhan']);
		$tnr_nguoigui = $_SESSION['uid'];
		$tnr_tieude = addslashes($_POST['tnr_tieude']);
		$tnr_noidung = addslashes($_POST['tnr_noidung']);
		$rs = $db->query("SELECT * FROM ".$prefix."nguoidung WHERE u_name = '".$tnr_nguoinhan."' AND u_banned = 1");
		if($db->num_rows($rs) != 0){
			$row = $db->fetch_array($rs);
			$tnr_nguoinhan_id = $row[u_id];
			
			$db->query("INSERT INTO ".$prefix."tinnhanrieng(tnr_tieude,tnr_noidung,tnr_nguoinhan,tnr_nguoigui,tnr_thoigian,tnr_danhdau,tnr_tinhtrang) VALUES('".$tnr_tieude."','".$tnr_noidung."','".$tnr_nguoinhan_id."','".$tnr_nguoigui."',now(),0,0)");
			Redirect("Gửi tin thành công !","".$root."/tin-nhan/");
		}else{
			$mess = "Người nhận này không tồn tại !";
		}	
	}
	
	
	if(isset($_GET['u_name'])){
		$u_name = $_GET['u_name'];
	}
?>
<div style="margin: 0pt; padding: 0pt; width: 750px;">
    <div class="TR">
        <div class="TL">
            <div class="BodyTop"></div>
        </div>
    </div>
<form action="" name="frmGuiTinNhan" id="frmGuiTinNhan" method="post">
    <div class="BodyCompose">   
        <p style="margin-bottom: 6px;">
            <label style="float: left; width: 66px;">Gởi đến</label><span><input id="tnr_nguoinhan" name="tnr_nguoinhan" class="com-text" value="<?=$u_name?>" type="text">
			</span>
        </p>  
		<div class="clearBoth"></div>
		<p style="margin-bottom:6px;">
			<label style="float: left; width: 66px;">&nbsp;</label>
			<?
				if($mess != ""){
			?>
			<span style="font-weight:bold; color:#FF0000;"><?=$mess?></span>
			<? } ?>
		</p>
        <div class="clearBoth"></div>
        <p style="margin-bottom: 6px;">
            <label style="float: left; width: 66px; line-height: 20px;">Tiêu đề</label><span><input id="tnr_tieude" name="tnr_tieude" class="com-text" value="" type="text"></span>
        </p>
        <div style="overflow: hidden; text-align: left; width: 700px;">

            <label style="float: left; width: 66px;">Nội dung</label>   
            <input id="submit" name="submit" type="hidden" value="1">                
            <div style="float: left; width: 620px; height: 350px;">
			<br style="line-height:5px;"/>
                <textarea id="elm1" name="tnr_noidung" style="width:30%; height:300px;"></textarea>
				
		    </div>		           
        </div>
        <div style="margin: 10px 0pt 0pt 80px;">
	        <input id="accept" src="<?=$root?>/themes/images/form/button-sent.jpg" class="com-button" type="image">			        
        </div> 
    </div>
</form>
    <div class="BR" style="margin-bottom: 4px;">
        <div class="BL">
            <div class="BodyBottom"></div>
        </div>
    </div>
</div>
